package com.ayne.network.server;

import java.io.IOException;

import com.ayne.network.packets.Registration;
import com.ayne.network.server.listener.NetworkListener;
import com.esotericsoftware.kryo.Kryo;
import com.esotericsoftware.kryonet.Server;
import com.esotericsoftware.minlog.Log;

public class Mainframe {
	private Server server;
	
	public Mainframe() throws IOException {
		start();
	}
	
	public static void main(String[] args) {
		try {
			new Mainframe();
			Log.set(Log.LEVEL_DEBUG);
		} catch (IOException exc) {
			exc.printStackTrace();
		}
	}
	
	public void start() throws IOException {
		server = new Server();
		registerPackets();
		server.addListener(new NetworkListener());
		server.bind(54555, 54556);
		server.start();
	}
	
	private void registerPackets() {
		Kryo kryo = server.getKryo();
		Registration.registerPackets(kryo);
	}
}
